<?php

namespace App\Models;

use Illuminate\Notifications\Notifiable;
use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Laravel\Passport\HasApiTokens;

class User extends AbstractModel implements   AuthenticatableContract, AuthorizableContract, CanResetPasswordContract
{
    use HasApiTokens,Notifiable,Authenticatable, Authorizable, CanResetPassword;
    const TABLE = 'users';
    protected $table = self::TABLE;

    protected $fillable = [
        'id','username','mobile','email', 'password','last_visited_ip'
    ];

    protected $appends = [
        'merchant','admin','infos'
    ];

    public function merchant()
    {
        return $this->hasOne('App\Models\Shop');
    }

    public function admin()
    {
        return $this->hasOne('App\Models\Admin');
    }

    public function infos()
    {
        return $this->hasOne('App\Models\Member');
    }

